package com.film.web.controller.cinema;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.film.common.annotation.Log;
import com.film.common.core.controller.BaseController;
import com.film.common.core.domain.AjaxResult;
import com.film.common.enums.BusinessType;
import com.film.cinema.domain.Crew;
import com.film.cinema.service.ICrewService;
import com.film.common.utils.poi.ExcelUtil;
import com.film.common.core.page.TableDataInfo;

/**
 * 剧组管理Controller
 * 
 * *@author fy
 * @date 2025-02-13
 */
@RestController
@RequestMapping("/cinema/crew")
public class CrewController extends BaseController
{
    @Autowired
    private ICrewService crewService;

    /**
     * 查询剧组管理列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:crew:list')")
    @GetMapping("/list")
    public TableDataInfo list(Crew crew)
    {
        startPage();
        List<Crew> list = crewService.selectCrewList(crew);
        return getDataTable(list);
    }

    /**
     * 导出剧组管理列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:crew:export')")
    @Log(title = "剧组管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Crew crew)
    {
        List<Crew> list = crewService.selectCrewList(crew);
        ExcelUtil<Crew> util = new ExcelUtil<Crew>(Crew.class);
        util.exportExcel(response, list, "剧组管理数据");
    }

    /**
     * 获取剧组管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:crew:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(crewService.selectCrewById(id));
    }

    /**
     * 新增剧组管理
     */
    @PreAuthorize("@ss.hasPermi('cinema:crew:add')")
    @Log(title = "剧组管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Crew crew)
    {
        return toAjax(crewService.insertCrew(crew));
    }

    /**
     * 修改剧组管理
     */
    @PreAuthorize("@ss.hasPermi('cinema:crew:edit')")
    @Log(title = "剧组管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Crew crew)
    {
        return toAjax(crewService.updateCrew(crew));
    }

    /**
     * 删除剧组管理
     */
    @PreAuthorize("@ss.hasPermi('cinema:crew:remove')")
    @Log(title = "剧组管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crewService.deleteCrewByIds(ids));
    }
}
